﻿using WebAPI.Filters;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using wt.wine.Application.Common.Models;
using wt.wine.Application.ManageSkutable;
using wt.wine.Application.ManageSkutable.Queries;
using wt.wine.Application.ManageSkutable.Command;

namespace WebAPI.Controllers.V1
{
    [ApiController]
    [Route("[controller]/[action]")]
    [LoginFilter]
    public class ManageSkutableController : ApiControllerBase
    {
        /// <summary>
        /// 【经销商】编辑设备绑定产品
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("AddUserTable")]
        [HttpPost]
        public async Task<Json<List<GetSkutableNameByUserIdDTO>>> GetSkutableNameByUserId([FromBody] GetSkutableNameByUserIdQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】新增商品
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageSkutable")]
        [HttpPost]
        public async Task<Json<string>> AddProduct([FromBody] AddSkutableCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 【经销商】:修改商品
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageSkutable")]
        [HttpPost]
        public async Task<Json<string>> EditProduct([FromBody] EditSkutableCommand command)
        {
            return await Mediator.Send(command);
        }

        /// <summary>
        /// 【经销商】商品列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("ManageSkutable")]
        [HttpPost]
        public async Task<Json<PaginatedList<GetSkutableListDTO>>> GetProductList([FromBody] GetSkutableListQueries query)
        {
            return await Mediator.Send(query);
        }

        /// <summary>
        /// 【经销商】设备加酒 获取商品列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [PermissioneFilter("GetDevicerecordList")]
        [HttpPost]
        public async Task<Json<PaginatedList<GetSkuTableNameAddWineListDTO>>> GetSkuTableNameAddWineList([FromBody] GetSkuTableNameAddWineListQueries query)
        {
            return await Mediator.Send(query);
        }
    }
}
